﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;

namespace Attendance
{
    public partial class frmPort : Form
    {
        string[] ports = SerialPort.GetPortNames();
        //public SerialPort serialPort1;

        public frmPort()
        {
            InitializeComponent();
            //MessageBox.Show(ports.GetValue(0).ToString());
            bgwCheckPorts.RunWorkerAsync();
        }

        private void bgwCheckPorts_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                
                if (ports.Length != 0)
                { break; }
            }
        }

        private void bgwCheckPorts_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else if (e.Cancelled == true)
            {
                MessageBox.Show("Cancelled");
            }
            else
            {
                
            }
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
